package com.yunbao.ioc.tx;

import java.sql.SQLException;

/**
 * Created by louisyuu on 2020/3/4 下午2:41
 */
public class TransactionManager {


    private ConnectionHolder connectionHolder;

    public void beganTransaction(){
        try {
            connectionHolder.getCurrentThreadConnection().setAutoCommit(false);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }




    public void commitTransaction(){
        try {
            connectionHolder.getCurrentThreadConnection().commit();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }



    public void rollback(){
        try {
            connectionHolder.getCurrentThreadConnection().rollback();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }


}
